<template>
  <div class="form-index-container">
    <div class="main-container">
      <div class="right-content-container">
        <router-view />
      </div>
    </div>
    <div class="btn-footer footer-container">
        <el-button size="small" type="info" icon="el-icon-view" @click="$router.back(-1)">返回</el-button>
        <el-button size="small" type="success" icon="el-icon-folder-add" @click="saveProjectAsTemplateHandle">保存</el-button>
        <el-button size="small" type="primary" icon="el-icon-view" @click="previewDialogVisible = true">预览</el-button>
    </div>
    <el-dialog :visible.sync="previewDialogVisible" destroy-on-close fullscreen>
      <pre-view :key="previewKey" :preview-qrcode="true" />
    </el-dialog>
  </div>
</template>

<script>
import PreView from '@/views/form/preview'

export default {
  name: 'NewIndex',
  components: { PreView },
  data() {
    return {
      previewKey: +new Date(),
      previewDialogVisible: false,
      defaultActiveMenu: 'editor',
      formKey: null
    }
  },
  created() {
    this.formKey = this.$route.query.key
    this.defaultActiveMenu = this.$route.path
  },
  methods: {
    openPreviewHandle() {
      this.previewKey = +new Date()
      this.previewDialogVisible = true
    },
    saveProjectAsTemplateHandle() {
      // templateSave({key:this.formKey}).then(res =>{
      //   if(res){
      //     if(res.code){
      //       this.$message.error(`${res.msg}`);
      //     }else{
      //       this.$message({
      //         message: '保存成功！',
      //         type: 'success'
      //       })
      //       setTimeout(()=>{
      //         this.$router.push({name: 'formDesigner'})
      //       }, 5000);
      //     }
      //   }
      // })
    }
  }
}
</script>

<style lang='scss' scoped>
.form-index-container {
  height: 100%;
  width: 100%;
  overflow: hidden;
}
::v-deep .el-card__body {
  padding: 0;
}
::v-deep .el-menu {
  border: none;
  background-color: transparent;
}
.footer-container {
  border-top: 1px solid #dfdfdf;
  height: 60px;
}
.main-container {
  width: 100%;
  height: calc(100vh - 60px);
  display: flex;
  flex-direction: row;
  margin-left:0 !important;
  .right-content-container {
    width: calc(100vw - 100px);
    height: calc(100vh - 60px);
    overflow-x: hidden;
  }
}
.left-menu-container {
  max-width: 100px;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: solid 1px #e6e6e6;
  .el-menu-vertical:not(.el-menu--collapse) {
    width: 100px;
    min-height: 400px;
  }
  .el-icon-d-arrow-left,
  .el-icon-d-arrow-right {
    font-size: 19px;
    cursor: pointer;
    font-weight: 550;
    color: #000;
    margin-bottom: 100px;
    &:hover {
      color: rgb(32, 160, 255);
    }
  }
}
::v-deep.preview-container {
  background-color: #ffffff;
}
</style>
